from django.shortcuts import render
from rest_framework import mixins
from rest_framework import viewsets

from .models import GoodsCategory, Goods
from .serializers import GoodsCategorySerializer, GoodsSerializer


class GoodsCategoryViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
    """
    list:商品分类列表数据
    """
    queryset = GoodsCategory.objects.filter(category_type=1)
    serializer_class = GoodsCategorySerializer


class GoodsViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
    """
    list:商品列表
    """
    queryset = Goods.objects.all()
    serializer_class = GoodsSerializer

